package game.zqll.systems;

import com.artemis.Entity;
import com.artemis.Manager;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import game.zqll.PluginFileHandle;
import game.zqll.components.BorderComp;
import game.zqll.components.DropComp;
import game.zqll.components.SpawnerComp;
import game.zqll.components.TextureRegionComp;

import java.util.Objects;

public class BorderTranRegionManager extends Manager {
    @Override
    public void added(Entity e) {
        BorderComp borderComp = e.getComponent(BorderComp.class);
        SpawnerComp spawnerComp = e.getComponent(SpawnerComp.class);
        if (borderComp != null && Objects.equals(spawnerComp.spawnId, "drop")) {
            TextureRegionComp textureRegionComp = e.edit().create(TextureRegionComp.class);
            textureRegionComp.region = new TextureRegion(new Texture(new PluginFileHandle("drop.png")));
            e.edit().remove(BorderComp.class);
            e.edit().create(DropComp.class);
        }
    }
}
